package com.zjbti.commonview;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;

public class Button extends AppCompatActivity implements View.OnClickListener{

    private Button button1;
    private Button button2;
    private Button button3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_button);
        button1=findViewById(R.id.button1);
        button2=findViewById(R.id.button2);
        button3=findViewById(R.id.button3);
        button3.setOnClickListener((View.OnClickListener) this);
        button1.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                button2.setText("按钮1已被点击");
            }
        });
    }

    public void click(View view) {
        button2.setText("按钮2已被点击");
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.button3:
                button3.setText("按钮3已被点击");
        }
    }
}